package com.aabte.permissionframeworklearn.permission.controller;

import com.aabte.permissionframeworklearn.permission.beans.PageQuery;
import com.aabte.permissionframeworklearn.permission.common.ResponseBean;
import com.aabte.permissionframeworklearn.permission.param.SearchLogParam;
import com.aabte.permissionframeworklearn.permission.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author Daniel
 */
@Controller
@RequestMapping("/sys/log")
public class SysLogController {

    @Autowired
    private SysLogService sysLogService;

    @GetMapping("/log.page")
    public ModelAndView page() {
        return new ModelAndView("log");
    }

    @PostMapping("/page.json")
    @ResponseBody
    public ResponseBean searchPage(
            SearchLogParam param,
            PageQuery page
    ) {
        return ResponseBean.success(sysLogService.searchPageList(param, page));
    }

    @PostMapping("/recover.json")
    @ResponseBody
    public ResponseBean recover(
            @RequestParam Long id
    ) {
        return ResponseBean.success(sysLogService.recover(id));
    }

}
